<?php
session_start();
if (isset($_SESSION['openid'])){
    include_once("../c/config.php");
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
    $openid=$_SESSION['openid'];
    $code=$_POST['code'];
    $cardid=$_POST['cid'];
    $thecode=$_POST['thecode'];
    $id=$_POST['id'];
    if(1 == $id){
        $mysqli->query("update play set ling1='yes' where thecode='".$thecode."' ");
    }
    if(2 == $id){
        $mysqli->query("update play set ling2='yes' where thecode2='".$thecode."' ");
    }
    if(3 == $id){
        $mysqli->query("update play set ling3='yes' where thecode3='".$thecode."' ");
    }
    if(4 == $id){
        $mysqli->query("update play set ling4='yes' where thecode4='".$thecode."' ");
    }
    
    $mysqli->query("insert into ucard(openid,name,thecode,cardid,createtime) values('".$openid."','".$code."','".$thecode."','".$cardid."','".date("Y-m-d H:i:s")."') ");
    
    echo 1;
}
?>
